package eva.savant.businessobject.gl;

import eva.savant.businessobject.vt.Canal;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Collection;

@Table(name="GL_MONEDA")
@javax.persistence.Entity(name = "gl.Moneda")
public class Moneda {

    @Id
    @Column(name = "ID_MONEDA", length = 2, nullable = false)
    private String id; //ID Moneda

    @Basic
    @Column(name = "NOMBRE", length = 30, nullable = false)
    private String nombre; //Nombre

    @Basic
    @Column(name = "ABREVIACION", length = 15, nullable = false)
    private String abreviacion; //Abreviacion

    @Basic
    @Column(name = "OPERACION_ID", length = 10, nullable = false)
    private Integer operacionId; //Operacion ID

    @Basic @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "FECHA_ID", length = 19, nullable = false)
    private Date fechaId; //Fecha Proceso ID

    @OneToMany
    (mappedBy = "moneda")
    private Collection<Cotizacion> lsCotizacion;

    @OneToMany
    (mappedBy = "moneda")
    private Collection<Pais> lsPais;

    @OneToMany
    (mappedBy = "moneda")
    private Collection<Canal> lsCanal;


    public Moneda(String id, String nombre, String abreviacion, Integer operacionId) {

        this.id= id;

        this.nombre= nombre;

        this.abreviacion= abreviacion;

        this.operacionId= operacionId;

    }

    public Moneda() {

    }


    public String getId() {
    
        return id;
    }
    
    public void setId(String id) {
    
        this.id = id;
    }

    public String getNombre() {
    
        return nombre;
    }
    
    public void setNombre(String nombre) {
    
        this.nombre = nombre;
    }

    public String getAbreviacion() {
    
        return abreviacion;
    }
    
    public void setAbreviacion(String abreviacion) {
    
        this.abreviacion = abreviacion;
    }

    public Integer getOperacionId() {
    
        return operacionId;
    }
    
    public void setOperacionId(Integer operacionId) {
    
        this.operacionId = operacionId;
    }

    public Collection<Cotizacion> getLsCotizacion() {
    
        return lsCotizacion;
    }
    
    public void setLsCotizacion(Collection<Cotizacion> lsCotizacion) {
    
        this.lsCotizacion = lsCotizacion;
    }

    public Collection<Pais> getLsPais() {
    
        return lsPais;
    }
    
    public void setLsPais(Collection<Pais> lsPais) {
    
        this.lsPais = lsPais;
    }

    public Collection<Canal> getLsCanal() {
    
        return lsCanal;
    }
    
    public void setLsCanal(Collection<Canal> lsCanal) {
    
        this.lsCanal = lsCanal;
    }

    @PreUpdate
    @PrePersist
    public void updateTimeFechaId() {

        this.fechaId = new Timestamp(new java.util.Date().getTime());
    }

}
